<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>意见建议</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/api.js"></script>
    <script type="text/javascript" src="./script/aui-tab.js"></script>
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <script type="text/javascript" src="./script/aui-slide.js"></script>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript">
        function closeWin() {
            api.closeWin({});
        };
    </script>
</head>

<body>
    <!-- 头部 -->
    <header class="aui-bar aui-bar-nav" id="topbar">
        <a class="aui-pull-left aui-btn" onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">意见建议</div>
    </header>
    <div class="guestbook">
        <textarea name="" id="text"></textarea>
        <button type="button" id="sub2">提交</button>
        <button type="button" class="active" style="display:none;" id="sub" tapmode onclick="updata()">提交</button>
    </div>
</body>
<script type="text/javascript">
    $('#text').on('keyup', function() {
        if ($('#text').val().length == 0) {

            $("#sub").hide();
            $("#sub2").show();
        } else {
            $("#sub").show();
            $("#sub2").hide();
        }
    });

    function updata() {

        var userid = $api.getStorage('userid');
        if (!userid) {
            is_login();
        } else {

      var text =  $("#text").val();

     api.ajax({
         url: 'http://www.big-wealth.com/index.php?ctl=app_user_center&act=reportguy',
         method: 'post',
         data: {
             values: {
                 user_id: userid,
                 reason:text
             },
         }
     },function(ret, err){
         if (ret.status == 1) {
             alert(ret.info);
             api.closeWin();
         } else {
             alert(ret.info);
         }
     });
        }
    };

    function is_login() {

        alert('请先登录');
        var delay = 0;

        api.openFrame({
            name: 'login',
            url: './login.html',
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: 'auto'
            },
            pageParam: {
                name: 'test'
            },
            bounces: true,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true
        });
        return false;

    }
</script>

</html>
